package com.km.team.phsystem.web.utils;

import java.io.UnsupportedEncodingException;
import java.util.Base64;

/**
 * Author: jiangjun
 * Date: 2018/10/19
 * Time: 下午3:52
 * Description:
 */
public class Base64Utils {

    public static String encode(String content) throws UnsupportedEncodingException {
        final Base64.Encoder encoder = Base64.getEncoder();

        final byte[] textByte = content.getBytes("UTF-8");
        //编码
        final String encodedText = encoder.encodeToString(textByte);
        return encodedText;
    }

    public static String decode(String encodedText) throws UnsupportedEncodingException {
        final Base64.Decoder decoder = Base64.getDecoder();
        return new String(decoder.decode(encodedText), "UTF-8");
    }
}
